<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1">
  <title id="af20941">CREATE COLLATION</title>
  <body>
    <p id="sql_command_desc">Defines a new collation using the specified operating system
      locale settings, or by copying an existing collation.</p>
    <section id="section2">
      <title>Synopsis</title>
      <codeblock id="sql_command_synopsis">CREATE COLLATION <varname>name</varname> (    
    [ LOCALE = <varname>locale</varname>, ]    
    [ LC_COLLATE = <varname>lc_collate</varname>, ]    
    [ LC_CTYPE = <varname>lc_ctype</varname> ])

CREATE COLLATION <varname>name</varname> FROM <varname>existing_collation</varname></codeblock>
    </section>
    <section id="section3">
      <title>Description</title>
      <p> To be able to create a collation, you must have <codeph>CREATE</codeph> privilege on the
        destination schema.</p>
    </section>
    <section id="section4">
      <title>Parameters</title>
      <parml>
        <plentry>
          <pt>
            <varname>name</varname>
          </pt>
          <pd> The name of the collation. The collation name can be schema-qualified. If it is not,
            the collation is defined in the current schema. The collation name must be unique within
            that schema. (The system catalogs can contain collations with the same name for other
            encodings, but these are ignored if the database encoding does not match.) </pd>
        </plentry>
        <plentry>
          <pt>
            <varname>locale</varname>
          </pt>
          <pd> This is a shortcut for setting <codeph>LC_COLLATE</codeph> and
              <codeph>LC_CTYPE</codeph> at once. If you specify this, you cannot specify either of
            those parameters.</pd>
        </plentry>
        <plentry>
          <pt>
            <varname>lc_collate</varname>
          </pt>
          <pd>Use the specified operating system locale for the <codeph>LC_COLLATE</codeph> locale
            category. The locale must be applicable to the current database encoding. (See <xref
              href="CREATE_DATABASE.xml#topic1" format="dita" type="topic"/> for the precise rules.)
          </pd>
        </plentry>
        <plentry>
          <pt>
            <varname>lc_ctype</varname>
          </pt>
          <pd>Use the specified operating system locale for the <codeph>LC_CTYPE</codeph> locale
            category. The locale must be applicable to the current database encoding. (See <xref
              href="CREATE_DATABASE.xml#topic1" format="dita" type="topic"/> for the precise
            rules.)</pd>
        </plentry>
        <plentry>
          <pt>
            <varname>existing_collation</varname>
          </pt>
          <pd> The name of an existing collation to copy. The new collation will have the same
            properties as the existing one, but it will be an independent object.</pd>
        </plentry>
      </parml>
    </section>
    <section id="section5">
      <title>Notes</title>
      <p>To be able to create a collation, you must have <codeph>CREATE</codeph> privilege on the
        destination schema.</p>
      <p>Use <codeph>DROP COLLATION</codeph> to remove user-defined collations.</p>
      <p>See <xref href="https://www.postgresql.org/docs/9.4/collation.html" format="html"
          scope="external">Collation Support</xref> in the PostgreSQL documentation for more
        information about collation support in Greenplum Database.</p>
    </section>
    <section id="section6">
      <title>Examples</title>
      <p>To create a collation from the operating system locale <codeph>fr_FR.utf8</codeph>
        (assuming the current database encoding is
        <codeph>UTF8</codeph>):<codeblock>CREATE COLLATION french (LOCALE = 'fr_FR.utf8');</codeblock>
      </p>
      <p>To create a collation from an existing
        collation:<codeblock>CREATE COLLATION german FROM "de_DE";</codeblock> This can be
        convenient to be able to use operating-system-independent collation names in applications.
      </p>
    </section>
    <section id="section7">
      <title>Compatibility</title>
      <p>There is a <codeph>CREATE COLLATION</codeph> statement in the SQL standard, but it is
        limited to copying an existing collation. The syntax to create a new collation is a
        Greenplum Database extension.</p>
    </section>
    <section id="section8">
      <title>See Also</title>
      <p>
        <codeph><xref href="./ALTER_COLLATION.xml#topic1" type="topic" format="dita"/></codeph>,
            <codeph><xref href="DROP_COLLATION.xml#topic1"/></codeph>
      </p>
    </section>
  </body>
</topic>
